---
hide_table_of_contents: true
---

# Chat Message History

:::info
Head to [Integrations](/docs/integrations/chat_memory/) for documentation on built-in chat message history integrations with 3rd-party databases and tools.
:::

One of the core utility classes underpinning most (if not all) memory modules is the `ChatMessageHistory` class. This is a wrapper that provides convenience methods for saving `HumanMessage`s, `AIMessage`s, and other chat messages and then fetching them.

You may want to use this class directly if you are managing memory outside of a chain.

Below is a basic example with an in-memory, ephemeral message store:

import CodeBlock from "@theme/CodeBlock";
import Example from "@examples/memory/chat_messages.ts";

<CodeBlock language="typescript">{Example}</CodeBlock>

The added messages are saved in memory rather than saved externally as a session.
For ways of persisting conversations, check out this [Integrations section](/docs/integrations/chat_memory/).
